package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.coupontemplate.CouponTemplateBO;
import com.micro.modual.model.dto.coupontemplate.CouponTemplateDetailDTO;
import com.micro.modual.model.dto.coupontemplate.CouponTemplateListDTO;
import com.micro.modual.model.dto.coupontemplate.CouponTemplateReceiveRecord;
import com.micro.modual.service.CouponTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>优惠券模版表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "优惠券模版管理",tags = "优惠券模版管理")
@RestController
@RequestMapping(value = "couponTemplate")
public class CouponTemplateController {

    @Autowired
    private CouponTemplateService couponTemplateService;

    /**
     * <h2>查找优惠券模版表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<CouponTemplateListDTO> {@link CouponTemplateListDTO}s  优惠券模版表 列表返回对象
     */
    @ApiOperation(value = "查询优惠券模版表列表" ,notes = "查询优惠券模版表列表")
    @GetMapping(value = "/findCouponTemplateList")
    public RespJsonPageData<CouponTemplateListDTO> findCouponTemplateList(@RequestParam  Map<String,Object> params){
        return couponTemplateService.findCouponTemplateList(params);
    }


    /**
     * <h2>根据主键编号查看优惠券模版表详情</h2>
     * @param templateCode  优惠券模版表 模版编号
     * @return {@link CouponTemplateDetailDTO}  优惠券模版表 详情
     */
    @ApiOperation(value = "查询优惠券模版表详情",notes = "根据主键编号，查询优惠券模版表详情")
    @GetMapping(value = "/findCouponTemplateDetail/{templateCode}")
    public RespJsonData<CouponTemplateDetailDTO> findCouponTemplateDetail(@PathVariable("templateCode") String  templateCode){
        return couponTemplateService.findCouponTemplateDetail(templateCode);
    }

    /**
     * <h2>查询优惠券模版领取记录</h2>
     * @param params 请求参数包含优惠券模版编号 分页参数
     * @return {@link CouponTemplateReceiveRecord} 优惠券领取记录
     */
    @GetMapping(value = "/findCouponTemplateReceiveRecord")
    public RespJsonPageData<CouponTemplateReceiveRecord> findCouponTemplateReceiveRecord(@RequestParam Map<String,Object> params){
        return couponTemplateService.findCouponTemplateReceiveRecord(params);
    }


    /**
     * <h2>新增优惠券模版表详情</h2>
     * @param couponTemplateBO {@link CouponTemplateBO} 优惠券模版表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增优惠券模版表",notes = "新增优惠券模版表")
    @PostMapping(value = "/addCouponTemplate")
    public RespJson addCouponTemplate(@RequestBody CouponTemplateBO couponTemplateBO){
        return couponTemplateService.addCouponTemplate(couponTemplateBO);
    }

    /**
     * <h2>修改优惠券模版表详情</h2>
     * @param couponTemplateBO  {@link CouponTemplateBO} 优惠券模版表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改优惠券模版表",notes = "修改优惠券模版表")
    @PostMapping(value = "/editCouponTemplate")
    public RespJson editCouponTemplate(@RequestBody CouponTemplateBO couponTemplateBO){
        return couponTemplateService.editCouponTemplate(couponTemplateBO);
    }

    /**
     * <h2>根据主键编号删除优惠券模版表信息</h2>
     * @param id  优惠券模版表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除优惠券模版表",notes = "根据地址ID，删除优惠券模版表")
    @PostMapping(value = "/deleteCouponTemplate/{id}")
    public RespJson deleteCouponTemplate(@PathVariable("id") Long id){
        return couponTemplateService.deleteCouponTemplate(id);
    }


    /**
     * <h2>校验优惠券模版名称是否存在</h2>
     * @param couponTempName 优惠券模版名称
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "校验优惠券模版名称是否存在",notes = "校验优惠券模版名称是否存在")
    @PostMapping(value = "/validataCouponTemplateNameExist/{couponTempName}")
    public RespJson validataCouponTemplateNameExist(@PathVariable("couponTempName") String couponTempName){
        return couponTemplateService.validataCouponTemplateNameExist(couponTempName);
    }
}

